<?php

namespace Home\Model;

class LogdataModel extends Model
{
    public function getByProjectCode($projectCode)
    {
        $data = [];
        $boughtModel = D('Bought');
        $stuffModel = D('DataView');
        foreach ($this->where(['project_code' => $projectCode])->select() as $row) {
            $row['module'] = $boughtModel->where(['project_code' => $projectCode, 'type' => $row['type']])->select();
            $row['stuff'] = $stuffModel->where(['project_code' => $projectCode, 'profession' => $row['type']])->find();
            $data[$row['type']] = $row;
        }

        return $data;
    }
}
